package cn.edu.swust.adressbook.dao;

import java.util.Map;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.AbstractDaoSession;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;

import cn.edu.swust.adressbook.bean.Contact;
import cn.edu.swust.adressbook.bean.Group;
import cn.edu.swust.adressbook.bean.CallLog;

import cn.edu.swust.adressbook.dao.ContactDao;
import cn.edu.swust.adressbook.dao.GroupDao;
import cn.edu.swust.adressbook.dao.CallLogDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see org.greenrobot.greendao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig contactDaoConfig;
    private final DaoConfig groupDaoConfig;
    private final DaoConfig callLogDaoConfig;

    private final ContactDao contactDao;
    private final GroupDao groupDao;
    private final CallLogDao callLogDao;

    public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        contactDaoConfig = daoConfigMap.get(ContactDao.class).clone();
        contactDaoConfig.initIdentityScope(type);

        groupDaoConfig = daoConfigMap.get(GroupDao.class).clone();
        groupDaoConfig.initIdentityScope(type);

        callLogDaoConfig = daoConfigMap.get(CallLogDao.class).clone();
        callLogDaoConfig.initIdentityScope(type);

        contactDao = new ContactDao(contactDaoConfig, this);
        groupDao = new GroupDao(groupDaoConfig, this);
        callLogDao = new CallLogDao(callLogDaoConfig, this);

        registerDao(Contact.class, contactDao);
        registerDao(Group.class, groupDao);
        registerDao(CallLog.class, callLogDao);
    }
    
    public void clear() {
        contactDaoConfig.clearIdentityScope();
        groupDaoConfig.clearIdentityScope();
        callLogDaoConfig.clearIdentityScope();
    }

    public ContactDao getContactDao() {
        return contactDao;
    }

    public GroupDao getGroupDao() {
        return groupDao;
    }

    public CallLogDao getCallLogDao() {
        return callLogDao;
    }

}
